
<script setup>
import { ref } from 'vue';
const progress = ref(0);

const handleUpload = (file) => {
  const worker = new Worker('./file-upload.worker.js');
  
  worker.postMessage({
    file,
    chunkSize: 5 * 1024 * 1024, // 5MB分片
    url:'/api/upload'
  });

  worker.onmessage = (e) => {
    if (e.data.type === 'progress') {
      progress.value = e.data.value;
    } else if (e.data.type === 'complete') {
      console.log('上传完成', e.data.results);
    }
  };
};
</script>
